<template>
    <!-- <div class="mui-numbox" data-numbox-step="10" data-numbox-min="10" data-numbox-max="90"> -->
    <div class="mui-numbox" data-numbox-min="1">
        <button class="mui-btn mui-btn-numbox-minus" type="button" disabled="">-</button>
        <input class="mui-input-numbox" type="number" value="1" @change="countChanged" ref="numbox">
        <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>
</template>

<script>
import mui from '../../lib/mui/js/mui.min.js'

export default {
    mounted () {
        mui('.mui-numbox').numbox()
    },
    props : {
        max : {
            type : Number
        }
    },
    methods : {
        countChanged () {
            // 每当 文本框的数据被修改的时候，立即把 最新的数据，通过事件调用，传递给父组件
            this.$emit("getCount", this.$refs.numbox.value)
        }
    },
    watch : {
        max : function (newVal, oldVal) {
            mui('.mui-numbox').numbox().setOption('max', newVal)
        }
    }
}
</script>

<style lang="scss" scoped>

</style>
